package com.topvision.elementanim.hualang;

import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AppCompatActivity;
import android.transition.Explode;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.topvision.elementanim.R;

public class ImageViewerActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView mImageView;
    private String res;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        getWindow().setExitTransition(new Explode());
        setContentView(R.layout.activity_image_view);
        res = getIntent().getStringExtra(Constants.RES_IMAGE);
        mImageView = (ImageView) findViewById(R.id.iv_viewer);
        ViewCompat.setTransitionName(mImageView, Constants.TRANSITION_NAME);
        mImageView.setOnClickListener(this);
        Glide.with(this).load(res).into(mImageView);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_viewer:
                ActivityCompat.finishAfterTransition(this);
                break;
        }
    }
}
